<template>
  <div>
      {{detailData}}
      <van-button type="primary" @click='addToCartFun'>加入购物车</van-button>
  </div>
</template>

<script>
export default {
    created() {
    },
    computed: {
        detailData() {
            return this.$store.state.shoppingList.filter((v,i) => {
                return v.id === this.$route.params.id;
            })[0]
        }
    },
    methods: {
        addToCartFun() {
            let newData = {...this.detailData}
            this.$store.commit('addToCart', {
                data: newData,
                count: 1,
            })
        }
    }
}
</script>

<style>

</style>